<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>用户列表</title>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript">
        function addCount(uid) {
            //ajax函数：执行异步请求
            $.ajax({
                url: 'add_count?uid='+uid,
                type: 'post',
                dataType: "json",
                success: function (data) {   //成功后回调，参数data为返回的数据
                    if (data.success) {
                        $("#cnt-"+data.uid).text(data.count);
                    }
                    //刷新页面
                    location = location;
                },
                error: function(error){    //失败后回调
                    alert("服务器连接失败");
                }
            })
        }
    </script>
</head>
<body>
  <h3 align="center">用户列表</h3>
  <table border="1" cellspacing="0" align="center" width="30%">
    <tr>
	  <th>编号</th>
	  <th>姓名</th>
	  <th>性别</th>
	  <th>年龄</th>
      <th>票数</th>
      <th>
        <a href="/goto_add" target="_blank">投票</a>
      </th>
	</tr>
      <#list userList as u>
      <tr>
          <td>${u.uid}</td>
          <td>${u.name}</td>
          <td>${u.sex}</td>
          <td>${u.age}</td>
          <td id="cnt-${u.uid}">${u.count}</td>
          <td>
              <a href="javascript:void(0);" onclick="addCount(${u.uid})">投票</a>
          </td>
      </tr>
      </#list>
</table>
</body>
</html>
